//
// Created by work on 24-5-30.
//

#ifndef IOT_PLAT_CUSERINFO_H
#define IOT_PLAT_CUSERINFO_H

#include <dist/json/json.h>
#include <os/miscellany/date_time.h>

namespace iotplat{

    class CUserInfo{
    public:
        enum EUserType {
            ERoot,
            EUser,
            EGuest
        };

        enum ERtUserCol{
            ECommunication_key,
            EState,
            EPulse,
            ELogin_time,
        };

        enum EUserCol {
            EUserId = 0X00,
            EPwd,
            ENickname,
            EUtype,
            EAdmin_usr,
            EConfigs,
            EMenu_permission,
            EProperty_permission,
            EGroupings,
            ECreate_time,
            EUpdate_time,
            ELast_online_time,
            ELast_login_time,
            EMail_address,
            EPhone_number
        };


        std::string userid;
        std::string pwd;
        std::string nickname;
        enum EUserType utype;
        std::string admin;
        Json::Value configs;
        Json::Value menu_permission;
        Json::Value property_permission;
        std::string grouping;
        CDateTime create_time;
        CDateTime update_time;
        CDateTime last_online_time;
        CDateTime last_login_time;
        std::string email_address;
        std::string phone_number;

        static std::map<CUserInfo::EUserCol, std::string> userColToStringMap;
    public:
        explicit CUserInfo();
        Json::Value toJson();

    };

    static const std::map<CUserInfo::ERtUserCol, std::string> userRtColToStringMap = {
            {CUserInfo::ECommunication_key, "communication_key"},
            {CUserInfo::EState, "state"},
            {CUserInfo::EPulse, "pulse"},
            {CUserInfo::ELogin_time, "login_time"}
    };

    static const char* t_user_name = "t_iot_user";

#define USER_ENUM                     CUserInfo::EUserCol
#define userFieldName(type)           CUserInfo::userColToStringMap.find(type)->second
}


#endif //IOT_PLAT_CUSERINFO_H
